package com.wh.controller.outstorehouse;

import com.wh.pojo.OutStorehouse;
import com.wh.service.outstorehouse.OutStorehouseService;
import com.wh.vo.PageResult;
import com.wh.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/outStorehouse/")
public class OutStorehouseController {

    @Autowired
    private OutStorehouseService outStorehouseService;



    @GetMapping("getQuery")
    public SysResult getQuery(OutStorehouse outStorehouse){
        Map<String,Object> map = outStorehouseService.getQuery(outStorehouse);
        return SysResult.success(map);
    }

    @GetMapping("list")
    public SysResult getOutStorehouseList(PageResult pageResult){
        pageResult = outStorehouseService.getOutStorehouseList(pageResult);
        return SysResult.success(pageResult);
    }

    @PostMapping("addOutStorehouse")
    public SysResult addOutStorehouse(@RequestBody OutStorehouse outStorehouse){
        outStorehouseService.addOutStorehouse(outStorehouse);
        return SysResult.success();
    }

    @PutMapping("updataOutStorehouse")
    public SysResult updataOutStorehouse(@RequestBody OutStorehouse outStorehouse){
        outStorehouseService.updataOutStorehouse(outStorehouse);
        return SysResult.success();
    }

    @DeleteMapping("dalete/{outStorehouseId}")
    public SysResult deleteOutStorehouse(@PathVariable String outStorehouseId){
//        outStorehouseService.deleteOutStorehouse(outStorehouseId);
        return SysResult.success("连接成功");
    }

    @PutMapping("out")
    public SysResult out(@RequestBody OutStorehouse outStorehouse){
        outStorehouseService.out(outStorehouse);
        return SysResult.success();
    }
}
